import request from "@/utils/request";

// 获取确认订单信息
export function getConfirmOrderInfo(query) {
  return request({
    url: `/web/order/confirm`,
    method: "get",
    params: {
      skuId: query.skuId,
      count: query.count,
    },
  });
}

// 提交订单
export function submitOrder(data) {
  return request({
    url: `/web/order/submit`,
    method: "post",
    data,
  });
}

// 支付
export function payOrderByAlipay(orderSn) {
  return request({
    url: `/payment/alipay/websitePay/${orderSn}`,
    method: "get",
  });
}

// 取消订单
export function closeOrderByAlipay(orderSn) {
  return request({
    url: `/order/info/cancel/${orderSn}`,
    method: "put",
  });
}
// 查询订单列表
export function listUserOrder(query) {
  return request({
    url: "/order/info/front/list",
    method: "get",
    params: query,
  });
}

// 订单详情
export function getOrderInfo(id) {
  return request({
    url: `/order/info/front/detail/${id}`,
    method: "get",
  });
}

// 获取订单商品项详情
export function getOrderItemInfo(id) {
  return request({
    url: `/order/item/${id}`,
    method: "get",
  });
}

// 删除订单
export function deleteOrder(id) {
  return request({
    url: `/order/info/${id}`,
    method: "delete",
  });
}
